<?php
// vim: set et sw=4 ts=4 sts=4 fdm=marker ff=unix fenc=utf8 nobomb:
/**
 * Jump to the newest Chromium Build download page
 *  this script is evolve from http://lab.fouland.com/chrome/update.php, thanks to Van
 *
 * @author mingcheng<i.feelinglucky#gmail.com>
 * @date   2009-11-19
 * @link   http://www.gracecode.com/
 */

define('SNAPSHOTS_URL', 'http://build.chromium.org/buildbot/snapshots/');

$platform = array(
    'linux'   => 'chromium-rel-linux',
    'linux64' => 'chromium-rel-linux-64',
    'win32'   => 'chromium-rel-xp',
    'mac'     => 'chromium-rel-mac'
);

switch($selected_platform = strtolower($_GET['platform'])) {
    case 'linux': case 'linux64': case 'win32': case 'mac':
        $uri = 'http://build.chromium.org/buildbot/snapshots/' . $platform[$selected_platform];
        try {
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $uri . '/LATEST');
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $version = curl_exec($curl);
            curl_close($curl);
            header("Location: " .$uri . '/' . $version . '/');
        } catch (Exception $e) {
            die('<h1>Request Error</h1>');
        }
    break;

    default:
        die('<h1>Request Empty</h1>');
}
